<?php


// https://github.com/kassner/log-parser



require __DIR__ . '/vendor/autoload.php';

$file_name="/Users/mac/zwn/zwn_git/simple_shell_course/apache_log/zwnPython/log/m-access_log_2021-04-05";
$dirFile='/Users/mac/zwn/zwn_git/simple_shell_course/apache_log/zwnPython/log/';


$parser = new \Kassner\LogParser\LogParser();
$lines = file($file_name, FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES);
// $lines = file('/var/log/apache2/access.log', FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES);


# default Nginx format:
/* 

$parser->setFormat('%h %l %u %t "%r" %>s %O "%{Referer}i" \"%{User-Agent}i"');


*/

$parser->setFormat("%h %{HTTP_HOST}e %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-agent}i\" %{UID}C %{SESSIONID}C");

foreach ($lines as $line) {
    $entry = $parser->parse($line);
	echo "<pre>";
	var_dump($entry );
}


